<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Boost.Convert Overhead</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Convert 2.0">
<link rel="up" href="../performance.html" title="Performance">
<link rel="prev" href="../performance.html" title="Performance">
<link rel="next" href="the_bigger_picture.html" title="The Bigger Picture">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../performance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../performance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_bigger_picture.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_convert.performance.boost_convert_overhead"></a><a class="link" href="boost_convert_overhead.html" title="Boost.Convert Overhead">Boost.Convert
      Overhead</a>
</h3></div></div></div>
<p>
        <span class="emphasis"><em>Boost.Convert</em></span> framework adds an additional layer of
        indirection and some <span class="emphasis"><em>Boost.Convert</em></span> converters are wrappers
        around actual conversion facilities such as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code>,
        <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span></code>, etc. Consequently, there might
        be reasonable concerns with regard to the performance overhead introduced
        by the framework as opposed to deploying conversion facilities directly.
      </p>
<p>
        To test that code has been borrowed and adapted from the Spirit.Qi performance/optimization
        framework (see $BOOST_ROOT/libs/spirit/workbench/qi/int_parser.cpp). The
        tests were
      </p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
            compiled using gcc-4.6.3 and gcc-4.8.2;
          </li>
<li class="listitem">
            with optimization: <code class="computeroutput"><span class="identifier">g</span><span class="special">++</span> <span class="special">-</span><span class="identifier">O3</span>
            <span class="identifier">test</span><span class="special">/</span><span class="identifier">performance_spirit</span><span class="special">.</span><span class="identifier">cpp</span> <span class="special">-</span><span class="identifier">Iinclude</span> <span class="special">-</span><span class="identifier">I</span><span class="special">../</span><span class="identifier">boost_1_56_0</span> <span class="special">-</span><span class="identifier">lrt</span></code>;
          </li>
<li class="listitem">
            on 64-bit Ubuntu 12.04 and 32-bit Ubuntu 14.04;
          </li>
<li class="listitem">
            run against the input of randomly generated 18 numeric strings (9 positive
            and 9 negative numbers with the number of digits from 1 to 9);
          </li>
<li class="listitem">
            run for
            <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                  <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lexical_cast</span></code>-based converter;
                </li>
<li class="listitem">
                  <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">parse</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">parse</span></code>-based
                  converter.
                </li>
</ul></div>
          </li>
</ol></div>
<p>
        The purpose of the test was to deploy the same functionality directly and
        as part of the <span class="emphasis"><em>Boost.Convert</em></span> framework. Results are
        shown below for several consecutive runs:
      </p>
<pre class="programlisting"><span class="identifier">gcc</span><span class="special">-</span><span class="number">4.6</span><span class="special">.</span><span class="number">3</span> <span class="special">(</span><span class="number">64</span><span class="special">-</span><span class="identifier">bit</span><span class="special">)</span>
<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0504170070</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span>
<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0610595810</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>
<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2845369110</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span>
<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2834834560</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>

<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0770350390</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span>
<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">1.0607665160</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>
<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2792295470</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span>
<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">0.2827574570</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>

<span class="identifier">gcc</span><span class="special">-</span><span class="number">4.8</span><span class="special">.</span><span class="number">2</span> <span class="special">(</span><span class="number">32</span><span class="special">-</span><span class="identifier">bit</span><span class="special">)</span>
<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.5153330600</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span>
<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.6989499850</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>
<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.4197476510</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span>
<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.4594171510</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">2</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>

<span class="identifier">raw_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.4136546980</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span>
<span class="identifier">cnv_lxcast_str_to_int_test</span><span class="special">:</span> <span class="number">8.5322524600</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">slower</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>
<span class="identifier">raw_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.3842388060</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">1</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">prev</span><span class="special">.</span> <span class="identifier">run</span><span class="special">)</span>
<span class="identifier">cnv_spirit_str_to_int_test</span><span class="special">:</span> <span class="number">2.3812094400</span> <span class="special">[</span><span class="identifier">s</span><span class="special">]</span> <span class="special">(</span><span class="number">0</span><span class="special">%</span> <span class="identifier">faster</span> <span class="identifier">than</span> <span class="identifier">raw</span> <span class="identifier">above</span><span class="special">)</span>
</pre>
<p>
        The results for consecutive runs varied with deviations of around 2%. Under
        2% was also the deviation of the "cnv" code compared to the "raw"
        code. That indicates that the <span class="emphasis"><em>Boost.Convert</em></span> framework
        had no detectable running overhead with the tested compilers, hardware and
        deployment scenarios. The results might be different on other platforms.
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2020 Vladimir Batov<p>
        Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../performance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../performance.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="the_bigger_picture.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
